﻿package com.vicentediaz.view.intro
{
    import com.greensock.*;
    import com.greensock.plugins.*;
    import com.myp.mystage.*;
    import com.vicentediaz.view.events.*;
    import com.vicentediaz.view.imageviewer.*;
    import flash.display.*;
    import flash.events.*;
    import flash.utils.*;

    public class Intro extends MovieClip
    {

        public function Intro()
        {
            addFrameScript(146, this.frame147, 181, this.frame182);
            var _loc_1:* = new Timer(7000, 1);
            _loc_1.start();
            _loc_1.addEventListener(TimerEvent.TIMER_COMPLETE, this.onTimerComplete, false, 0, true);
            TweenPlugin.activate([FrameLabelPlugin]);
            ImageViewer.getInstance().addEventListener(ImageViewerEvent.IMAGE_LOADED, this.onFirstImageLoaded, false, 0, true);
            TweenMax.to(this, 5, {frameLabel:"start"});
            addEventListener(Event.ADDED_TO_STAGE, this.onAddedToStage, false, 0, true);
            return;
        }// end function

        private function onAddedToStage(param1:Event) : void
        {
            MyStage.getInstance().stage.addEventListener(Event.RESIZE, this.onResize, false, 0, true);
            this.onResize(null);
            return;
        }// end function

        private function onResize(param1:Event) : void
        {
            this.x = MyStage.getInstance().centerX;
            this.y = MyStage.getInstance().centerY;
            return;
        }// end function

        private function onFirstImageLoaded(param1:ImageViewerEvent) : void
        {
            TweenMax.to(this, 1.5, {frameLabel:"end"});
            ImageViewer.getInstance().removeEventListener(ImageViewerEvent.IMAGE_LOADED, this.onFirstImageLoaded);
            ImageViewer.getInstance().addEventListener(ImageViewerEvent.IMAGE_LOADED, this.onSecondImageLoaded, false, 0, true);
            return;
        }// end function

        function frame147()
        {
            stop();
            return;
        }// end function

        private function onSecondImageLoaded(param1:ImageViewerEvent) : void
        {
            TweenMax.to(this, 1, {alpha:0, visible:false});
            return;
        }// end function

        function frame182()
        {
            stop();
            return;
        }// end function

        private function onTimerComplete(param1:TimerEvent) : void
        {
            dispatchEvent(new IntroEvents(IntroEvents.FINISH));
            return;
        }// end function

    }
}
